home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9888 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: sunrise.gv.ssi1.com!news
  2. From: Mike Palmer <Mike.Palmer@tus.ssi1.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: accessing the printer or serial port
  5. Date: 5 Mar 1996 01:43:12 GMT
  6. Organization: Silicon Systems, Inc.
  7. Message-ID: <4hg67g$65t@atlas.tus.ssi1.com>
  8. References: <31387AFD.7184@gramercy.ios.com>
  9. NNTP-Posting-Host: pc259u.tus.ssi1.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
  14.  
  15. Storm Orisak <stormer@gramercy.ios.com> wrote:
  16. >Could someone please post the command to send bits out through the 
  17. >serial or parallel port in MSVC 4.0.
  18. >
  19. >Thanks
  20.  
  21. I presume you are using an IBM compatible PC (someone around here is trying to do 
  22. this on an HP workstation, and finding it to be much more difficult...)
  23.  
  24. If you want to write to the printer, the easiest way to do it is to use DOS or BIOS 
  25. services. That stuff is pretty well documented in many books, so I won't describe it 
  26. in more detail here. 
  27.  
  28. If you want to actually write bits out, and you don't want any extra handshaking or 
  29. anything else (in my application, I use the parallel port to talk to a port on an IC 
  30. we designed, so I just want to be able to make the parallel port pins go high and 
  31. low at my command).
  32.  
  33. For the parallel port, the command you want is outportb(). You hand it a port number 
  34. and a byte, and it puts it out directly. The port locations can be found using 
  35. debug: have it dump the memory at 0040:0000. The last eight bytes on the first line 
  36. of the dump are the ports for the installed parallel ports. In the listing below 
  37. (from my computer), 78 03 is the port 0x0378 (LPT1). The reason you should find the 
  38. port addresses at this memory location is that they can be at different locations on 
  39. different computers. In some IBM PS/2 computers, for example, LPT1 is at a different 
  40. port.
  41.  
  42. 0040:0000  F8 03 F8 02 00 00 00 00-78 03 00 00 00 00 00 00 ........x.......
  43.  
  44. Then, you just write to that port using outportb, and whatever you write appears 
  45. there.
  46.  
  47. There is no similar way to output specific bits in this manner from the serial port, 
  48. and although I did some serial port programming years ago, I can't remember enough 
  49. of it to be helpful...
  50.  
  51. Hope the information I've provided helps...
  52.  
  53. -- Mike --
  54.  
  55.  
  56.  
  57.  
  58.  
  59.